class LogsController < ApplicationController
  #DESC: Monitoreo de acciones realizadas en el Bitacorh.
  #MODULE: Utilitarios
  # GET /logs
  # GET /logs.xml
  def index
  end

  # GET /logs/1
  # GET /logs/1.xml
  def show
    @log = Log.find(params[:id])
    
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @log }
    end
  end
 
  def datos #IGNORE
    #Realizar consulta
    registros, count = find_by_params(params, :class => Log)
    # Construct a hash from the ActiveRecord result
    return_data = Hash.new()
    return_data[:page] = params[:page]
    return_data[:total] = (count.to_f / params[:rows].to_i).ceil
    return_data[:records] = count
    return_data[:rows] = registros.collect{|u| {:id=>u.id,
        :cell=>[ 
          u.usuario.try(:nombres),u.accion.try(:nombre),u.params,u.ip,u.created_at.strftime("%d/%m/%Y - %H:%M")
        ]}}

    # Convert the hash to a json object
    render :text=>return_data.to_json, :layout=>false
  end
  
end
